/*
 * Copyright (C) 2008 Universidade Federal de Campina Grande
 *  
 * This file is part of OurGrid. 
 *
 * OurGrid is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free 
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version. 
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package org.ourgrid.acceptance.worker;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.ourgrid.acceptance.util.WorkerAcceptanceUtil;
import org.ourgrid.acceptance.util.worker.Req_004_Util;
import org.ourgrid.acceptance.util.worker.Req_006_Util;
import org.ourgrid.acceptance.util.worker.Req_079_Util;
import org.ourgrid.acceptance.util.worker.Req_080_Util;
import org.ourgrid.acceptance.util.worker.Req_082_Util;
import org.ourgrid.acceptance.util.worker.Req_087_Util;
import org.ourgrid.acceptance.util.worker.Req_088_Util;
import org.ourgrid.acceptance.util.worker.Req_090_Util;
import org.ourgrid.acceptance.util.worker.Req_091_Util;
import org.ourgrid.acceptance.util.worker.Req_092_Util;
import org.ourgrid.acceptance.util.worker.Req_095_Util;
import org.ourgrid.acceptance.util.worker.Req_120_Util;
import org.ourgrid.acceptance.util.worker.Req_121_Util;
import org.ourgrid.common.interfaces.Worker;
import org.ourgrid.common.interfaces.WorkerClient;
import org.ourgrid.common.interfaces.management.RemoteWorkerManagementClient;
import org.ourgrid.common.interfaces.management.WorkerManagementClient;
import org.ourgrid.common.interfaces.to.WorkerStatus;
import org.ourgrid.common.util.JavaFileUtil;
import org.ourgrid.reqtrace.ReqTest;
import org.ourgrid.worker.WorkerComponent;
import org.ourgrid.worker.WorkerConfiguration;
import org.ourgrid.worker.dao.EnvironmentDAO;
import org.ourgrid.worker.utils.RandomNumberUtil;

import br.edu.ufcg.lsd.commune.identification.ContainerID;
import br.edu.ufcg.lsd.commune.identification.DeploymentID;
import br.edu.ufcg.lsd.commune.processor.filetransfer.IncomingTransferHandle;
import br.edu.ufcg.lsd.commune.processor.filetransfer.TransferHandle;
import br.edu.ufcg.lsd.commune.test.AcceptanceTestUtil;

@ReqTest(reqs="REQ080")
public class Req_080_Test extends WorkerAcceptanceTestCase {
	
	private DeploymentID peerID;
	private Req_004_Util req_004_Util = new Req_004_Util(getComponentContext());
	private Req_090_Util req_090_Util = new Req_090_Util(getComponentContext());
	private Req_092_Util req_092_Util = new Req_092_Util(getComponentContext());
	private Req_080_Util req_080_Util = new Req_080_Util(getComponentContext());
	private Req_079_Util req_079_Util = new Req_079_Util(getComponentContext());
	private Req_006_Util req_006_Util = new Req_006_Util(getComponentContext());
	private Req_121_Util req_121_Util = new Req_121_Util(getComponentContext());
	private Req_120_Util req_120_Util = new Req_120_Util(getComponentContext());
	private Req_095_Util req_095_Util = new Req_095_Util(getComponentContext());
	private Req_087_Util req_087_Util = new Req_087_Util(getComponentContext());
	private Req_088_Util req_088_Util = new Req_088_Util(getComponentContext());	
	private Req_091_Util req_091_Util = new Req_091_Util(getComponentContext());
	private Req_082_Util req_082_Util = new Req_082_Util(getComponentContext());
		
	private static final String playpenDirName  = "worker-4962768465676381896";
	private static final String playpenDirAName = "worker-4437113781045784766";
	private static final String playpenDirBName = "worker-6688467811848818630";
	private static final String playpenDirCName = "worker-930398729812583683";
	private static final String playpenDirDName = "worker-1799392825646950253";
	private static final String playpenDirEName = "worker-3076577384771227573";
	private static final String playpenDirFName = "worker-2117885745830041267";
	private static final String playpenDirGName = "worker-279624296851435688";
	private static final String playpenDirHName = "worker-6994682892532625671";
	private static final String playpenDirIName = "worker-8139610853772939505";
	
	@Before
	public void setUp() throws Exception {
		super.setUp();
		String peerPubKey = workerAcceptanceUtil.simulateAuthentication();
		peerID = new DeploymentID(new ContainerID("username", "server", "module", peerPubKey),"peer");
	}

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1" with handle "0" and size 323 bytes;
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$PLAYPEN/file1] with size 323 bytes. Handle: 0. Unknown client public key: [mgPublicKey222].
	 *           * Expect the Worker to reject the file transfer;
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. A client with the public key "mgPublicKey222" requests to transfer the file "file1" size 123 bytes and handle "1";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file1] with size 123 bytes. Handle: 1. Unknown client public key: [mgPublicKey222].
	 *           * Expect the Worker to reject the file transfer;
	 *    7. The master peer commands the Worker to work for the client with the public key "publicKeyABC";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [publicKeyABC]."
	 *           * Verify if the following info message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1" with size 256 bytes and handle "2";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$PLAYPEN/file1] with size 256 bytes. Handle: 2. Unknown client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *    9. A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/file2" with size 525 bytes and handle "3";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$STORAGE/file2] with size 525 bytes. Handle: 3. Unknown client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   10. A client with the public key "mgPublicKey1" requests to transfer the file "dir/$ABC/etc" with size 678 bytes and handle "4";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [dir/$ABC/etc] with size 678 bytes. Unknown client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   11. A client with the public key "mgPublicKey1" requests to transfer the file "file1" size 123 bytes and handle "1";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file1] with size 123 bytes. Handle: 1. Unknown client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   12. A client with the public key "publicKeyABC" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID2].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. A client with the public key "mgPublicKey1" requests to transfer the file "file2" size 133 bytes and handle "2";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file2] with size 133 bytes. Handle: 2. Unknown client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 * 
	 */
	@ReqTest(test=" AT-080.1", reqs="REQ080")
	@Test public void test_at_080_1_UnknownLocalClientTriesToSendFile() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		ContainerID senderID = new ContainerID("client", "clientServer", "broker", "mgPublicKey222");
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1" 
		// with handle "0" and file size 323 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(0, "$PLAYPEN/file1", 323,  "$PLAYPEN/file1", "description", senderID), 323);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file1" 
		// with handle "1" and file size 123 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 123, "file1", "description", senderID), 123);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKeyABC"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKeyABC");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		ContainerID senderID2 = new ContainerID("client2", "clientServer", "broker", "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1" 
		// with handle "2" and file size 256 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "$PLAYPEN/file1", 
				new IncomingTransferHandle(2, "$PLAYPEN/file1", 256, "$PLAYPEN/file1", "description", senderID2), 256);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/file2" 
		// with handle "3" and file size 525 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "$STORAGE/file2", 
				new IncomingTransferHandle(3, "$STORAGE/file2", 525, "$STORAGE/file2", "description", senderID2), 525);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "dir/$ABC/etc" 
		// with handle "4" and file size 678 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "dir/$ABC/etc", 
				new IncomingTransferHandle(1, "dir/$ABC/etc", 678, "dir/$ABC/etc", "description", senderID2), 678);
		
		//A client with the public key "mgPublicKeyABC" sends a startWork message
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKeyABC"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid2ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file2" 
		// with handle "2" and file size 133 bytes - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "file2", 
				new IncomingTransferHandle(2, "file2", 133, "file2", "description", senderID2), 133);
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1" with size 256 bytes and handle "1";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$PLAYPEN/file1] with size 256 bytes. Handle: 1. Unknown client public key: [mgPublicKey222]. 1 A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. A client with the public key "mgPublicKey222" requests to transfer the file "file1" with size 123 bytes and handle "2";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file1] with size 123 bytes. Handle: 2. Unknown client public key: [mgPublicKey222].
	 *    7. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKeyABC";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKeyABC]."
	 *           * Verify if the following info message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1" with size 256 bytes and handle "3";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$PLAYPEN/file1] with size 256 bytes. Handle: 3. Unknown client public key: [mgPublicKey1].
	 *    9. A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/file2" with size 256 bytes and handle "4";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$STORAGE/file2] with size 256 bytes. Handle: 4. Unknown client public key: [mgPublicKey1].
	 *   10. A client with the public key "mgPublicKey1" requests to transfer the file "dir/$ABC/etc" with size 256 bytes and handle "5";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file ["dir/$ABC/etc"] with size 256 bytes. Handle: 5. Unknown client public key: [mgPublicKey1].
	 *   11. A client with the public key "mgPublicKey1" requests to transfer the file "file1" with size 256 bytes and handle "6";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file1] with size 256 bytes. Handle: 6. Unknown client public key: [mgPublicKey1].
	 *   12. A client with the public key "mgPublicKeyABC" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID2].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. A client with the public key "mgPublicKey222" requests to transfer the file "file2" with size 123 bytes and handle "2";
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [file2] with size 123 bytes. Handle: 2. Unknown client public key: [mgPublicKey222].
	 * 
	 */
	@ReqTest(test=" AT-080.2", reqs="REQ080")
	@Test public void test_at_080_2_UnknownRemoteClientTriesToSendFile() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		ContainerID senderID = new ContainerID("client", "clientServer", "broker", "mgPublicKey222");
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1"
		// with size 256 bytes and handle "1" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(1, "$PLAYPEN/file1", 256, "$PLAYPEN/file1", "description", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file1"
		// with size 123 bytes and handle "2" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "file1", 
				new IncomingTransferHandle(2, "file1", 123, "file1", "description", senderID), 123);
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKeyABC"
		rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorker(component, "peerPubKey", "mgPublicKeyABC");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		ContainerID senderID2 = new ContainerID("client2", "clientServer", "broker", "mgPublicKey1");
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1"
		// with size 256 bytes and handle "3" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(3, "$PLAYPEN/file1", 256, "$PLAYPEN/file1", "description", senderID), 256);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/file2"
		// with size 256 bytes and handle "4" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "$STORAGE/file2", 
				new IncomingTransferHandle(4, "$STORAGE/file2", 256, "$STORAGE/file2", "description", senderID2), 256);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "dir/$ABC/etc"
		// with size 256 bytes and handle "5" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "$PLAYPEN/file1", 
				new IncomingTransferHandle(5, "$PLAYPEN/file1", 256, "$PLAYPEN/file1", "description", senderID2), 256);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1"
		// with size 256 bytes and handle "6" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "file1", 
				new IncomingTransferHandle(6, "file1", 256, "file1", "description", senderID2), 256);
		
		//A client with the public key "mgPublicKeyABC" sends a startWork message
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKeyABC"),
				"myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid2ID);
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file2"
		// with size 123 bytes and handle "2" - expected a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(2, "$PLAYPEN/file1", 123, "$PLAYPEN/file1", "description", senderID), 123);
	} 
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "file", with unknown transfer description "null", size 256 bytes and handle "5";
	 *           * Verify if the following error message was logged: "The client tried to transfer a file with a unknown transfer description. This message was ignored. Transfer description: [null]. Client public key: [mgPublicKey1]."
	 *           * Expect the Worker to reject the file transfer;
	 *    6. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    7. A client with the public key "mgPublicKey1" requests to transfer the file "file", with unknown transfer description "TRANSFER", size 256 bytes and handle "5";
	 *           * Verify if the following error message was logged: "The client tried to transfer a file with a unknown transfer description. This message was ignored. Transfer description: [TRANSFER]. Client public key: [mgPublicKey1]."
	 *           * Expect the Worker to reject the file transfer;
	 *    8. The master peer sends a stopWorking message to the Worker;
	 *           * Verify if the following info message was logged: "This Worker was commanded to stop working for the current client."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to IDLE."
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    9. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   10. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   11. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   12. A client with the public key "mgPublicKey222" requests to transfer the file "file", with unknown transfer description "null", size 256 bytes and handle "5";
	 *           * Verify if the following error message was logged: "The client tried to transfer a file with a unknown transfer description. This message was ignored. Transfer description: [null]. Client public key: [mgPublicKey222]."
	 *           * Expect the Worker to reject the file transfer;
	 *   13. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   14. A client with the public key "mgPublicKey222" requests to transfer the file "file", with unknown transfer description "GET", size 256 bytes and handle "5";
	 *           * Verify if the following error message was logged: "The client tried to transfer a file with a unknown transfer description. This message was ignored. Transfer description: [GET]. Client public key: [mgPublicKey222]."
	 *           * Expect the Worker to reject the file transfer;
	 * 
	 */
	@ReqTest(test=" AT-080.3", reqs="REQ080")
	@Test public void test_at_080_3_ClientTriesToSendFileWithInvalidDescription() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file",
		// with unknown transfer description "null", size 256 bytes and handle "5" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidDescription(component, 1, senderID,
				"file", new IncomingTransferHandle(5, "file", 256, "file", null, senderID), 256, null);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file",
		// with unknown transfer description "TRANSFER", size 256 bytes and handle "5" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidDescription(component, 1, senderID,
				"file", new IncomingTransferHandle(5, "file", 256, "file", "TRANSFER", senderID), 256, "TRANSFER");
		
		//The master peer sends a stopWorking message to the Worker
		req_091_Util.stopWorkingOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey());
		
		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work for
		// the remote client with the public key "mgPublicKey222"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey222");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);

		//A client with the public key "mgPublicKey222" sends a startWork message
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mg2UserName", "mg2Server", "mg2Module", "mgPublicKey222"), "myGrid2");
		
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid2ID);
		
		ContainerID senderID2 = myGrid2ID.getContainerID();
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file",
		// with unknown transfer description "null", size 256 bytes and handle "5" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidDescription(component, 1, senderID2,
				"file", new IncomingTransferHandle(5, "file", 256, "file", null, senderID2), 256, null);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid2ID);
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file",
		// with unknown transfer description "GET", size 256 bytes and handle "5" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidDescription(component, 1, senderID2,
				"file", new IncomingTransferHandle(5, "file", 256, "file", "GET", senderID2), 256, "GET");
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "null", with size 256 bytes and the handle "1";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is null]. File path: [null]. Size: 256 bytes. Handle: 1. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *    6. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    7. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/$STORAGE/temp", with size 256 bytes and the handle "2";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [Invalid variable found.]. File path: [$PLAYPEN/$STORAGE/temp]. Size: 256 bytes. Handle: 2. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *    8. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    9. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/../../$STORAGE", with size 256 bytes and the handle "3";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [Invalid variable found.]. File path: [$PLAYPEN/../../$STORAGE]. Size: 256 bytes. Handle: 3. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   10. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   11. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/../../system", with size 256 bytes and the handle "4";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is not relative to "absolutePath" directory.]. File path: [$PLAYPEN/../../system]. Size: 256 bytes. Handle: 3. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   12. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. A client with the public key "mgPublicKey1" requests to transfer the file "../../system", with size 256 bytes and the handle "5";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is not relative to "absolutePath" directory.]. File path: [../../system]. Size: 256 bytes. Handle: 3. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 * 
	 */
	@ReqTest(test=" AT-080.4", reqs="REQ080")
	@Test public void test_at_080_4_LocalClientTriesToSendFileToInvalidDirectory() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "null",
		// with size 256 bytes and the handle "1" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithNullFilePath(component, 1, senderID, 
				new IncomingTransferHandle(1, null, 256, null, "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$ABC/temp",
		// with size 256 bytes and the handle "6" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidVariable(component, 1, senderID, "$ABC/temp", 
				new IncomingTransferHandle(6, "$ABC/temp", 256, "$ABC/temp", "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/$STORAGE/temp",
		// with size 256 bytes and the handle "3" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidVariable(component, 1, senderID, "$PLAYPEN/$STORAGE/temp", 
				new IncomingTransferHandle(3, "$PLAYPEN/$STORAGE/temp", 256, "$PLAYPEN/$STORAGE/temp", "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/../../system",
		// with size 256 bytes and the handle "4" - expect a warn to be logged
		String playpenRoot = (String) properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String playpenDir = playpenRoot + File.separator + playpenDirName;
		req_080_Util.requestToTransferFileWithNotRelativePath(component, 1, senderID, "$PLAYPEN/../../system",
				new IncomingTransferHandle(4, "$PLAYPEN/../../system", 256, "$PLAYPEN/../../system", "PUT", senderID), 256, playpenDir);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "../../system",
		// with size 256 bytes and the handle "5" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithNotRelativePath(component, 1, senderID, "../../system", 
				new IncomingTransferHandle(5, "../../system", 256, "../../system", "PUT", senderID), 256, playpenDir);
	} 
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. A client with the public key "mgPublicKey1" requests to transfer the file "null", with size 256 bytes and the handle "1";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is null]. File path: [null]. Size: 256 bytes. Handle: 1. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *    7. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "$ABC/temp", with size 256 bytes and the handle "6";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [Invalid variable found.]. File path: [$ABC/temp]. Size: 256 bytes. Handle: 6. Client public key: [mgPublicKey1].
	 *    9. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   10. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/../$STORAGE", with size 256 bytes and the handle "6";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [Invalid variable found.]. File path: [$PLAYPEN/../$STORAGE]. Size: 256 bytes. Handle: 6. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   11. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   12. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/teste/$STORAGE/temp", with size 256 bytes and the handle "3";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [Invalid variable found.]. File path: [$PLAYPEN/teste/$STORAGE/temp]. Size: 256 bytes. Handle: 3. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   13. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   14. A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/../../system", with size 256 bytes and the handle "4";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is not relative to "absolutePath" directory.]. File path: [$STORAGE/../../system]. Size: 256 bytes. Handle: 4. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *   15. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   16. A client with the public key "mgPublicKey1" requests to transfer the file "../../system", with size 256 bytes and the handle "5";
	 *           * Verify if the following error message was logged: The client tried to transfer the file, but error occur on solving path. This message was ignored. Error cause: [File path is not relative to "absolutePath" directory.]. File path: [../../system]. Size: 256 bytes. Handle: 5. Client public key: [mgPublicKey1].
	 *           * Expect the Worker to reject the file transfer;
	 *           
	 */
	@ReqTest(test=" AT-080.5", reqs="REQ080")
	@Test public void test_at_080_5_RemoteClientTriesToSendFileToInvalidDirectory() throws Exception {
		//Start Worker with idleness detector DISABLED
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "null",
		// with size 256 bytes and the handle "1" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithNullFilePath(component, 1, senderID, 
				new IncomingTransferHandle(1, null, 256, null, "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$ABC/temp",
		// with size 256 bytes and the handle "6" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidVariable(component, 1, senderID, "$ABC/temp", 
				new IncomingTransferHandle(6, "$ABC/temp", 256, "$ABC/temp", "PUT", senderID), 256);

		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/../$STORAGE",
		// with size 256 bytes and the handle "6" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidVariable(component, 1, senderID, "$PLAYPEN/../$STORAGE", 
				new IncomingTransferHandle(6, "$PLAYPEN/../$STORAGE", 256, "$PLAYPEN/../$STORAGE", "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/teste/$STORAGE/temp",
		// with size 256 bytes and the handle "6" - expect a warn to be logged
		req_080_Util.requestToTransferFileWithInvalidVariable(component, 1, senderID, "$PLAYPEN/teste/$STORAGE/temp", 
				new IncomingTransferHandle(3, "$PLAYPEN/teste/$STORAGE/temp", 256, "$PLAYPEN/teste/$STORAGE/temp", "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/../../system",
		// with size 256 bytes and the handle "4" - expect a warn to be logged
		String storageRoot = (String) properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		String hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey1");
		String storageDir = storageRoot + File.separator + hashedMGPubKey;
		req_080_Util.requestToTransferFileWithNotRelativePath(component, 1, senderID, "$STORAGE/../../system", 
				new IncomingTransferHandle(4, "$STORAGE/../../system", 256, "$STORAGE/../../system", "PUT", senderID), 256, storageDir);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		RandomNumberUtil.setSeed(0L);
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "../../system",
		// with size 256 bytes and the handle "5" - expect a warn to be logged
		String playpenRoot = (String) properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String playpenDir = playpenRoot + File.separator + playpenDirName;
		req_080_Util.requestToTransferFileWithNotRelativePath(component, 1, senderID, "../../system", 
				new IncomingTransferHandle(5, "../../system", 256, "../../system", "PUT", senderID), 256, playpenDir);
	} 
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED and the playpen root property set to a read-only directory;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 256 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: "The client tried to transfer a file, but this Worker was not commanded to start the work yet. This message was ignored. Client public key: [mgPublicKey1]."
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following error message was logged: The client [clientID] tried to start the work of this Worker, but the playpen directory cannot be created.
	 *           * Expect the Worker to send the client an error ocurred message with the IO_ERROR type
	 *    6. A client with the public key "mgPublicKey1" requests to transfer the file "file2", with size 256 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: "The client tried to transfer a file, but this Worker was not commanded to start the work yet. This message was ignored. Client public key: [mgPublicKey1]."
	 *  
	 */
	@ReqTest(test=" AT-080.6", reqs="REQ080")
	@Test public void test_at_080_6_LocalClientThatDidNotStartWorkerTriesToSendFile() throws Exception {
		//Creating read-only playpen root directory
		String playpenRoot = System.getProperty("java.io.tmpdir") + File.separator + "readOnly";
		WorkerAcceptanceUtil.createDirectory(playpenRoot, true);
		
		//Start worker without idleness detector
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		properties.put(WorkerConfiguration.PROP_PLAYPEN_ROOT, playpenRoot);
		WorkerComponent component = req_004_Util.startWorker(false, true, false);
		
		//Master peer sends setPeer to the worker
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the worker to work for a client "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		ContainerID senderID = new ContainerID("client", "clientServer", "broker", "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" tries to transfer the file "file1",
		// with size 256 bytes and the handle "1" - expect a warn to be logged
		
		req_080_Util.requestToTransferFileOnUnstartedWorker(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 256, "file1", "PUT", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		// expect a warn to be logged
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkWithPlaypenError(component, worker, myGrid1ID, playpenRoot);
		
		senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" tries to transfer the file "file2",
		// with size 256 bytes and the handle "2" - expect a warn to be logged
		
		req_080_Util.requestToTransferFileOnUnstartedWorker(component, 1, senderID, "file2", 
				new IncomingTransferHandle(2, "file2", 256, "file2", "PUT", senderID), 256);
		
	} 
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED and the playpen root property set to a read-only directory;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 256 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: "The client tried to transfer a file, but this Worker was not commanded to start the work yet. This message was ignored. Client public key: [mgPublicKey1]."
	 *    6. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following error message was logged: The client [clientID] tried to start the work of this Worker, but the playpen directory cannot be created.
	 *           * Expect the Worker to send the client an error ocurred message with the IO_ERROR type
	 *    7. A client with the public key "mgPublicKey1" requests to transfer the file "file2", with size 256 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: "The client tried to transfer a file, but this Worker was not commanded to start the work yet. This message was ignored. Client public key: [mgPublicKey1]."
	 *  
	 */
	@ReqTest(test=" AT-080.7", reqs="REQ080")
	@Test public void test_at_080_7_RemoteClientThatDidNotStartWorkerTriesToSendFile() throws Exception {
		//Creating read-only playpen root directory
		String playpenRoot = System.getProperty("java.io.tmpdir") + File.separator + "readOnly";
		WorkerAcceptanceUtil.createDirectory(playpenRoot, true);
		
		//Start Worker with idleness detector DISABLED
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		properties.put(WorkerConfiguration.PROP_PLAYPEN_ROOT, playpenRoot);
		WorkerComponent component = req_004_Util.startWorker(false, true, false);
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		ContainerID senderID = new ContainerID("client", "clientServer", "broker", "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" tries to transfer the file "file1",
		// with size 256 bytes and the handle "1" - expect a warn to be logged
		req_080_Util.requestToTransferFileOnUnstartedWorker(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 256, "file1", "description", senderID), 256);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		// expect a warn to be logged
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		req_079_Util.startWorkWithPlaypenError(component, worker, myGrid1ID, playpenRoot);
		
		senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" tries to transfer the file "file2",
		// with size 256 bytes and the handle "2" - expect a warn to be logged
		req_080_Util.requestToTransferFileOnUnstartedWorker(component, 1, senderID, "file2", 
				new IncomingTransferHandle(2, "file2", 256, "file2", "description", senderID), 256);
		
	} 
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "root/file", with size 256 bytes and the handle "0";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/root/file]. File size: 256 bytes. Handle: 0.
	 *           * Expect the Worker to accept the file transfer;
	 *    6. A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1" with handle "0" and size 323 bytes;
	 *           * Verify if the following warn message was logged: An unknown client tried to transfer the file [$PLAYPEN/file1] with size 323 bytes. Handle: 0. Unknown client public key: [mgPublicKey222].
	 *           * Expect the Worker to reject the file transfer;
	 *    7. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey2", for the file transfer with handle 0 and 12 bytes of written data;
	 *           * Verify if the following warn message was logged: The worker received an incoming transfer failed message from a unknown client. This message was ignored. Client public key: [mgPublicKey2].
	 *    8. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 0 and 12 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/root/file]. Amount of data received: 12 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *    9. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   10. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   11. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following error message was logged: The client tried to transfer a file with a repeated handle. This message was ignored. Client public key: [mgPublicKey1]. Handle: 1.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "1";
	 *   12. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 323 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer failed message with unknown handle. Client public key: [mgPublicKey1]. Handle: 1.
	 *   14. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   15. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 0 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/file1]. Amount of data received: 0 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *   16. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   17. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2", with size 512 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file2]. File size: 512 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   18. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file3", with size 512 bytes and the handle "3";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file3]. File size: 512 bytes. Handle: 3.
	 *           * Expect the Worker to accept the file transfer;
	 *   19. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 1045 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/file2]. Amount of data received: 1045 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *   20. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer failed message with unknown handle. Client public key: [mgPublicKey1]. Handle: 2.
	 * 
	 */
	@ReqTest(test=" AT-080.8", reqs="REQ080")
	@Test public void test_at_080_8_SendFileFailByLocalClient() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "root/file",
		// with size 256 bytes and the handle "0"
		req_080_Util.requestToTransferFile(component, 1, senderID, "root"+File.separator+"file", 
				new IncomingTransferHandle(0, "root"+File.separator+"file", 256, "root"+File.separator+"file",
						"PUT", senderID), 256);
		
		ContainerID senderID2 = new ContainerID("client2", "clientServer", "broker", "mgPublicKey222");
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "$PLAYPEN/file1",
		// with handle "0" and size 323 bytes - expect a warn to be logged
		req_080_Util.requestToTransferFileByUnknownClient(component, 1, senderID2, "$PLAYPEN"+File.separator+"file1", 
				new IncomingTransferHandle(0, "$PLAYPEN"+File.separator+"file1", 323, "$PLAYPEN"+File.separator+"file1",
						"PUT", senderID2), 323);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey2",
		// for the file transfer with handle 0 and 12 bytes of written data
		req_080_Util.receiveIncomingTransferFailedFromUnknownClient(component, worker, workerClient,
				new IncomingTransferHandle(null, 12, "PUT", null), new Exception(), 12, "mgPublicKey2");
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 0 and 12 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "root"+File.separator+"file",
				new IncomingTransferHandle(0, "root"+File.separator+"file", 12, "root"+File.separator+"file",
						"PUT", senderID), new Exception(), 12, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file", 
				new IncomingTransferHandle(1, "file", 512, "file", "PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 0 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file",
				new IncomingTransferHandle(1, "file", 0, "file", "PUT", senderID), new Exception(), 0, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN"+File.separator+"file1", 
				new IncomingTransferHandle(1, "$PLAYPEN"+File.separator+"file1", 512, "$PLAYPEN"+File.separator+"file1",
						"PUT", senderID), 512);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1" - expect a error to be logged
		req_080_Util.requestToTransferFileWithRepeatedHandleAndFilesOnTransfer(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 512, "file1", "PUT", senderID),
				512, workerClient, AcceptanceTestUtil.createList(new IncomingTransferHandle(1, "file1", 512, "PUT","file1", senderID)));
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 323 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferFailedWithUnknownHandle(component, worker, workerClient,
				new IncomingTransferHandle(null, 323, "file1", "PUT"), new Exception(), 323, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 512, "file1", "PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 0 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file1",
				new IncomingTransferHandle(1, "file1", 0, "file1", "PUT", senderID), new Exception(), 0, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2",
		// with size 1256 bytes and the handle "2"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN"+File.separator+"file2", 
				new IncomingTransferHandle(2, "$PLAYPEN"+File.separator+"file2", 512L, "$PLAYPEN"+File.separator+"file2",
						"PUT", senderID), 1256);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file3",
		// with size 512 bytes and the handle "3"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN"+File.separator+"file3", 
				new IncomingTransferHandle(3, "$PLAYPEN"+File.separator+"file3", 512, "$PLAYPEN"+File.separator+"file3",
						"PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 1045 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file2",
				new IncomingTransferHandle(2, "file2", 1045, "file2", "PUT", senderID), new Exception(), 1045, "mgPublicKey1");
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 2 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferFailedWithUnknownHandle(component, worker, workerClient, 
				new IncomingTransferHandle(null, 2, null, "PUT"),
				new Exception(), 2, "mgPublicKey1");
	} 

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. A client with the public key "mgPublicKey1" requests to transfer the file "root/file", with size 512 bytes and the handle "0";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/root/file]. File size: 512 bytes. Handle: 0.
	 *           * Expect the Worker to accept the file transfer;
	 *    7. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey2", for the file transfer with handle 0 and 12 bytes of written data;
	 *           * Verify if the following warn message was logged: The worker received an incoming transfer failed message from a unknown client. This message was ignored. Client public key: [mgPublicKey2].
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "root/file", with size 512 bytes and the handle "1";
	 *           * Verify if the following warn message was logged: The client tried to transfer a file that is being received. This message was ignored. Client public key: [mgPublicKey1]. File destination: [playpenDir/root/file].
	 *           * Expect the Worker to reject the file transfer;
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "0";
	 *    9. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   10. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 0 and 12 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer failed message with unknown handle. Client public key: [mgPublicKey1]. Handle: 0.
	 *   11. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 0 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/file1]. Amount of data received: 0 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *   12. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   14. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file3", with size 512 bytes and the handle "3";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file3]. File size: 512 bytes. Handle: 3.
	 *           * Expect the Worker to accept the file transfer;
	 *   15. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 0 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/file1]. Amount of data received: 0 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *   16. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   17. A client with the public key "mgPublicKey1" requests to transfer the file "file2", with size 512 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file2]. File size: 512 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   18. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 1045 bytes of written data;
	 *           * Verify if the following error message was logged: Error while trying to receive file from client. Reporting error to client. Client public key: [mgPublicKey1]. Destination path: [playpenDir/file2]. Amount of data received: 1045 bytes.
	 *           * Expect the Worker to send the client a error ocurred message, with the IO_ERROR type
	 *   19. The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer failed message with unknown handle. Client public key: [mgPublicKey1]. Handle: 2.
	 * 
	 */
	@ReqTest(test=" AT-080.9", reqs="REQ080")
	@Test public void test_at_080_9_SendFileFailByRemoteClient() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "root/file",
		// with size 512 bytes and the handle "0"
		req_080_Util.requestToTransferFile(component, 1, senderID, "root"+File.separator+"file", 
				new IncomingTransferHandle(0, "root"+File.separator+"file", 512, "root"+File.separator+"file",
						"PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey2",
		// for the file transfer with handle 0 and 12 bytes of written data
		req_080_Util.receiveIncomingTransferFailedFromUnknownClient(component, worker, workerClient,
				new IncomingTransferHandle(0, null, 12, null, "description", new ContainerID("user", "server", "broker", "mgPublicKey2")),
				new Exception(), 12, "mgPublicKey2");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "root/file",
		// with size 512 bytes and the handle "1" - expect a error to be logged
		req_080_Util.requestToTransferIncomingFile(component, 1, senderID, "root"+File.separator+"file",
				new IncomingTransferHandle(1, "root"+File.separator+"file", 512, "root"+File.separator+"file", "PUT", senderID), 512, 
				AcceptanceTestUtil.createList(new IncomingTransferHandle(0, "root"+File.separator+"file", 512, "root"+File.separator+"file",
						"description", senderID)));
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 512, "file1", "PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 0 and 12 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferFailedWithUnknownHandle(component, worker, workerClient,
				new IncomingTransferHandle(0, null, 12, null, "PUT", new ContainerID("user", "server", "broker", "mgPublicKey1")), 
				new Exception(), 12, "mgPublicKey1");
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 0 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file1",
				new IncomingTransferHandle(1, "file1", 0, "file1", "PUT", senderID), new Exception(), 0, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 512, "file1", "PUT", senderID), 512);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file3",
		// with size 512 bytes and the handle "3"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN"+File.separator+"file3", 
				new IncomingTransferHandle(3, "$PLAYPEN"+File.separator+"file3", 512, "$PLAYPEN"+File.separator+"file3",
						"PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 323 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file1",
				new IncomingTransferHandle(1, "file1", 323, "file1", "PUT", senderID), new Exception(), 323, "mgPublicKey1");
		
		List<TransferHandle> handles = new ArrayList<TransferHandle>();
		handles.add(new IncomingTransferHandle(3, "$PLAYPEN"+File.separator+"file3", 512, "$PLAYPEN"+File.separator+"file3",
				"PUT", senderID));
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyWithFileOnTransfer(component, worker, myGrid1ID, true, handles);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 512, "file1", "PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 1 and 0 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file1",
				new IncomingTransferHandle(1, "file1", 0, "file1", "PUT", senderID), new Exception(), 0, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file2",
		// with size 512 bytes and the handle "2"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file2", 
				new IncomingTransferHandle(2, "file2", 512, "file2", "PUT", senderID), 512);
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 0 bytes of written data
		req_080_Util.receiveIncomingTransferFailed(component, worker, workerClient, "file2",
				new IncomingTransferHandle(2, "file2", 0, "file2", "PUT", senderID), new Exception(), 0, "mgPublicKey1");
		
		//The Worker receives an incoming transfer failed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 2 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferFailedWithUnknownHandle(component, worker, workerClient, 
				new IncomingTransferHandle(null, 2, null, "PUT"),
				new Exception(), 2, "mgPublicKey1");
	}

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "root/file", with size 256 bytes and the handle "0";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/root/file]. File size: 256 bytes. Handle: 0.
	 *           * Expect the Worker to accept the file transfer;
	 *    6. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey2", for the file transfer with handle 1 and 12 bytes of written data;
	 *           * Verify if the following warn message was logged: The worker received an incoming transfer completed message from a unknown client. This message was ignored. Client public key: [mgPublicKey2].
	 *    7. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 256 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 256 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *    8. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 0 and 1268 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 0. Amount of data received: 1268 bytes.
	 *    9. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 3556 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 3556 bytes.
	 *   10. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1", with size 256 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 256 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   11. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 3236 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 3236 bytes.
	 *   12. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file2", with size 1123 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file2]. File size: 1123 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   13. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 1123 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 2. Amount of data received: 1123 bytes.
	 *   14. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file2", with size 2555 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file2]. File size: 2555 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   15. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2555 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 2. Amount of data received: 2555 bytes.
	 *   16. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 2.
	 * 
	 */
	@ReqTest(test=" AT-080.10", reqs="REQ080")
	@Test public void test_at_080_10_LocalClientSendFileWithSuccess() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();

		//A client with the public key "mgPublicKey1" requests to transfer the file "root/file",
		// with size 256 bytes and the handle "0"
		req_080_Util.requestToTransferFile(component, 1, senderID, "root/file", 
				new IncomingTransferHandle(0, "root/file", 256, "root/file", "PUT", senderID), 256);

		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey2",
		// for the file transfer with handle 1 and 12 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferCompletedFromUnknownClient(component, worker, 
				new IncomingTransferHandle(1, null, 12, null, "description", new ContainerID("user", "server", "broker", "mgPublicKey2")),
				12, "mgPublicKey2");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 256 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 256, "file1", "PUT", senderID), 256);

		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 0 and 1268 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(0, null, 1268, null, "PUT", senderID), 1268, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 3556 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(1, null, 3556, null, "PUT", senderID), 3556, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1", 
		// with size 256 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(1, "$PLAYPEN/file1", 256, "$PLAYPEN/file1", "PUT", senderID), 256);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 3236 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(1, null, 3236, null, "PUT", senderID), 3236, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file2", 
		// with size 1123 bytes and the handle "2"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/dir/file2", 
				new IncomingTransferHandle(2, "$PLAYPEN/dir/file2", 256, "$PLAYPEN/dir/file2", "PUT", senderID), 256);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 2 and 1123 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(2, null, 3556, null, "PUT", senderID), 3556, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file2", 
		// with size 2555 bytes and the handle "3"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/dir/file2", 
				new IncomingTransferHandle(3, "$PLAYPEN/dir/file2", 256, "$PLAYPEN/dir/file2", "PUT", senderID), 256);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 3 and 2555 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(3, null, 3556, null, "PUT", senderID), 3556, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 2 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker,
				new IncomingTransferHandle(2, null, 2, null, "PUT", senderID), 2, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "testFile", 
		// with size 256 bytes, the handle "4" and local file name is different from remote file name 
		req_080_Util.requestToTransferFile(component, 1, senderID, "testFile", 
				new IncomingTransferHandle(4, "testFile", 256, "remoteTestFile", "PUT", senderID), 256);
		
	}

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. A client with the public key "mgPublicKey1" requests to transfer the file "/root/file", with size 1123 bytes and the handle "0";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file]. File size: 1123 bytes. Handle: 0.
	 *           * Expect the Worker to accept the file transfer;
	 *    7. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey2", for the file transfer with handle 1 and 12 bytes of written data;
	 *           * Verify if the following warn message was logged: The worker received an incoming transfer completed message from a unknown client. This message was ignored. Client public key: [mgPublicKey2].
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 3556 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 3556 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *    9. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 0 and 1123 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 0. Amount of data received: 1268 bytes.
	 *   10. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 3556 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 3556 bytes.
	 *   11. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1", with size 1123 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 1123 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   12. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 1123 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 1123 bytes.
	 *   13. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2", with size 55 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file2]. File size: 55 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   14. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file3", with size 22 bytes and the handle "3";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file3]. File size: 22 bytes. Handle: 3.
	 *           * Expect the Worker to accept the file transfer;
	 *   15. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 55 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 2. Amount of data received: 55 bytes.
	 *   16. The Worker receives an incoming transfer completed message, for the file transfer with handle 3 and 22 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 3. Amount of data received: 22 bytes.
	 *   17. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file3", with size 55 bytes and the handle "4";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file3]. File size: 55 bytes. Handle: 4.
	 *           * Expect the Worker to accept the file transfer;
	 *   18. The Worker receives an incoming transfer completed message, for the file transfer with handle 4 and 55 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 4. Amount of data received: 55 bytes.
	 *   19. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 4 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 4.
	 * 
	 */	
	@ReqTest(test=" AT-080.11", reqs="REQ080")
	@Test public void test_at_080_11_RemoteClientSendFileWithSuccess() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		ContainerID senderID = myGrid1ID.getContainerID();
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "root/file",
		// with size 1123 bytes and the handle "0"
		req_080_Util.requestToTransferFile(component, 1, senderID, "root/file", 
				new IncomingTransferHandle(0, "root/file", 1123, "root/file", "PUT", senderID), 1123);

		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey2",
		// for the file transfer with handle 1 and 12 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferCompletedFromUnknownClient(component, worker, 
				new IncomingTransferHandle(1, null, 12, null, "PUT", new ContainerID("user", "server", "broker", "mgPublicKey2")),
				12, "mgPublicKey2");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 3556 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				new IncomingTransferHandle(1, "file1", 3556, "file1", "PUT", senderID), 3556);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 0 and 1123 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(0, null, 1123, null, "PUT", senderID), 1123, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 3556 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(1, null, 3556, null, "PUT", senderID), 3556, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file1",
		// with size 1123 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/file1", 
				new IncomingTransferHandle(1, "$PLAYPEN/file1", 3556, "$PLAYPEN/file1", "PUT", senderID), 3556);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 1123 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(1, null, 1123, null, "PUT", senderID), 1123, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2",
		// with size 55 bytes and the handle "2"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/file2", 
				new IncomingTransferHandle(2, "$PLAYPEN/file2", 55, "$PLAYPEN/file2", "PUT", senderID), 55);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file3",
		// with size 22 bytes and the handle "3"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/dir/file3", 
				new IncomingTransferHandle(3, "$PLAYPEN/dir/file3", 22, "$PLAYPEN/dir/file3", "PUT", senderID), 22);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 2 and 55 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(2, null, 55, null, "PUT", senderID), 55, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 3 and 22 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(3, null, 22, null, "PUT", senderID), 22, "mgPublicKey1");

		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/dir/file3",
		// with size 55 bytes and the handle "4"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/dir/file3", 
				new IncomingTransferHandle(4, "$PLAYPEN/dir/file3", 44, "$PLAYPEN/dir/file3", "PUT", senderID), 44);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 4 and 55 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, 
				new IncomingTransferHandle(4, null, 55, null, "PUT", senderID), 55, "mgPublicKey1");

		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 4 and 2 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker,
				new IncomingTransferHandle(4, null, 2, null, "PUT", senderID), 2, "mgPublicKey1");
		
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "testFile", 
		// with size 256 bytes, the handle "5" and local file name is different from remote file name 
		req_080_Util.requestToTransferFile(component, 1, senderID, "testFile", 
				new IncomingTransferHandle(5, "testFile", 256, "remoteTestFile", "PUT", senderID), 256);
	}

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *    5. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *    7. Verify if the playpen directory exists and contains no files;
	 *    8. Copy the file test_080_15.txt to the playpen directory;
	 *    9. The master peer sends again a setPeer message to the Worker;
	 *           * Verify if the following warn message was logged: The peer [peerID2] set itself as manager of this Worker. This message was ignored. Because the master peer did not notify fail.
	 *   10. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   11. Verify if the previous playpen directory exists;
	 *   12. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   13. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   14. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   15. Verify if the playpen directory exists and contains no files;
	 *   16. Copy the file test_080_15.txt to the playpen directory;
	 *   17. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   18. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   19. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   20. Verify if the previous playpen directory does not exist;
	 *   21. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   22. Verify if the new playpen directory exists and contains no files;
	 *   23. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirA"
	 *   24. The same client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   25. Verify if the previous playpen directory does not exist;
	 *   26. Verify if the new playpen directory exists and contains no files;
	 *   27. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirB"
	 *   28. A client with the public key "mgPublicKey1", with a different ID, sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID2].
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   29. Verify if the previous playpen directory does not exist;
	 *   30. Verify if the new playpen directory exists and contains no files;
	 *   31. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirC"
	 *   32. Copy the file test_080_15.txt to the playpen directory;
	 *   33. Pause the Worker;
	 *           * Verify if the following info message was logged: "Worker has been PAUSED."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to OWNER."
	 *           * Expect the Worker to send the peer a status changed message, with the OWNER status
	 *   34. Verify if the previous playpen directory does not exist;
	 *   35. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   36. Resume the Worker;
	 *           * Verify if the following info message was logged: "Worker has been RESUMED."
	 *           * Verify if the following debug message was logged: "Status changed from OWNER to IDLE."
	 *           * Verify if the ControlClient received the operation succeed message
	 *   37. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   38. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   39. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey333";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey333]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   40. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   41. A client with the public key "mgPublicKey333" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   42. Verify if the playpen directory exists and contains no files;
	 *   43. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   44. The master peer sends again a setPeer message to the Worker;
	 *           * Verify if the following warn message was logged: The peer [peerID2] set itself as manager of this Worker. This message was ignored. Because the master peer did not notify fail.
	 *   45. Verify if the previous playpen directory exists;
	 *   46. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   47. The master peer sends a stopWorking message to the Worker;
	 *           * Verify if the following info message was logged: "This Worker was commanded to stop working for the current client."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to IDLE."
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *   48. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   49. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey333";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey333]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   50. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   51. A client with the public key "mgPublicKey333" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   52. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   53. Verify if the playpen directory exists and contains no files;
	 *   54. The master peer commands the Worker to work for a peer with the publicKey peerPubKey222;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey222]."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   55. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   56. Verify if the previous playpen directory does not exist;
	 *   57. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey444";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey444]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   58. A client with the public key "mgPublicKey444" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID4].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   59. Verify if the playpen directory exists and contains no files;
	 *   60. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   61. Copy the file test_080_15.txt to the playpen directory;
	 *   62. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey555";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey555]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   63. Verify if the previous playpen directory does not exist;
	 *   64. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   65. A client with the public key "mgPublicKey555" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID5].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   66. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   67. Verify if the new playpen directory exists and contains no files;
	 *   68. Copy the file test_080_15.txt to the playpen directory;
	 *   69. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   70. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   71. Verify if the previous playpen directory does not exist;
	 *   72. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   73. Verify if the new playpen directory exists and contains no files;
	 *   74. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   75. Copy the file test_080_15.txt to the playpen directory;
	 *   76. The master peer sends a stopWorking message to the Worker;
	 *           * Verify if the following info message was logged: "This Worker was commanded to stop working for the current client."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to IDLE."
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *   77. Verify if the previous playpen directory does not exist;
	 *   78. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 * 
	 */
	@ReqTest(test=" AT-080.12", reqs="REQ080")
	@Test public void test_at_080_12_CleaningWorkerWithSuccess() throws Exception {
		//Start Worker with idleness detector DISABLED
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey222");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//Verify if the playpen and storage directory are null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		DeploymentID myGrid0ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey222"), "myGrid");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the playpen directory exists and contains no files
		String playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		File pDir = new File(playpenPath);
		
		String storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		File sDir = new File(storagePath);
		
		Map<String, String> envVars = new HashMap<String, String>();
		String playpenDir = pDir.getAbsolutePath();
		String storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Copy the file test_080_11.txt to the playpen directory
		String file1Path = playpenDir + File.separator + "test_080_11.txt";
		WorkerAcceptanceUtil.createFile(file1Path);
		
		//The master peer sends again a setPeer message to the Worker - expect a warn to be logged
		req_090_Util.setPeerByMasterPeerFromSameLocation(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, wmc);
		
		//Verify if the playpen directory is "playpenDir"
		String storageRoot = (String) properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		String hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey222");
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Verify if the previous playpen directory exists
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey222");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the playpen directory exists and contains no files
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Copy the file test_080_15.txt to the playpen directory
		String file2Path = playpenDir + File.separator + "test_080_15.txt";
		WorkerAcceptanceUtil.createFile(file2Path);
		
		//Verify if the playpen directory is "playpenDir"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey222");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey1");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);

		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirA = playpenDir;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirA));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirA));
		
		//Verify if the playpen directory is "playpenDir"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey1");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);

		//The same client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirB = playpenDir;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirB));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirB));
		
		//Verify if the playpen directory is "playpenDirB"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//A client with the public key "mgPublicKey1", with a different ID, sends a startWork message
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey1"), "myGrid");
		
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid2ID);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDirB));
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirC = playpenDir;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirC));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirC));
		
		//Verify if the playpen directory is "playpenDirC"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Copy the file test_080_15.txt to the playpen directory
		String file3Path = playpenDirC + File.separator + "test_080_15.txt";
		WorkerAcceptanceUtil.createFile(file3Path);
		
		//Pause the Worker
		req_087_Util.pauseAllocatedForMyGridWorker(component, wmc);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDirC));
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.OWNER, null, null, 0);
		
		//Resume the Worker
		req_088_Util.resumeOwnerWorker(wmc, component);
		
		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_PEER, null, null, 0);
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client
		// with the public key "mgPublicKey333"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey333");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey333" sends a startWork message
		DeploymentID myGrid3ID = new DeploymentID(new ContainerID("mg3UserName", "mg3Server", "mg3Module", "mgPublicKey333"), "myGrid3");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//Verify if the playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey333");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//The master peer sends again a setPeer message to the Worker
		req_090_Util.setPeerByMasterPeerFromSameLocation(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, wmc);
		
		//Verify if the previous playpen directory exists
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Master peer sends a stopWorking message
		req_091_Util.stopWorkingOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey());
		
		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client
		// with the public key "mgPublicKey333"
		rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey333");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);

		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey333" sends a startWork message
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//Verify if the playpen directory exists and contains no files;
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//The master peer commands the Worker to work for a peer with the publicKey peerPubKey222
		req_006_Util.workForPeerOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey(), "peerPubKey222");
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_PEER, null, null, 0);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client
		// with the public key "mgPublicKey444"
		rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey222", "mgPublicKey444");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey444" sends a startWork message
		DeploymentID myGrid4ID = new DeploymentID(new ContainerID("mg4UserName", "mg4Server", "mg4Module", "mgPublicKey444"), "myGrid4");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid4ID);
		
		//Verify if the playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey444");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Copy the file test_080_15.txt to the playpen directory
		String file4Path = playpenDir + File.separator + "test_080_15.txt";
		WorkerAcceptanceUtil.createFile(file4Path);
		
		//The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client
		// with the public key "mgPublicKey555"
		rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorker(component, "peerPubKey222", "mgPublicKey555");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey555" sends a startWork message
		DeploymentID myGrid5ID = new DeploymentID(new ContainerID("mg5UserName", "mg5Server", "mg5Module", "mgPublicKey555"), "myGrid5");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid5ID);
		
		//Verify if the playpen directory is "playpenDir"
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey555");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Verify if the new playpen directory exists and contains no files
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Copy the file test_080_15.txt to the playpen directory
		String file5Path = playpenDir + File.separator + "test_080_15.txt";
		WorkerAcceptanceUtil.createFile(file5Path);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey222");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		storageRoot = (String) properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey222");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Copy the file test_080_15.txt to the playpen directory
		String file6Path = playpenDir + File.separator + "test_080_15.txt";
		WorkerAcceptanceUtil.createFile(file6Path);
		
		//The master peer sends a stopWorking message to the Worker
		req_091_Util.stopWorkingOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey());
		
		//Verify if the previous playpen directory does not exist
		assertFalse(WorkerAcceptanceUtil.directoryExists(playpenDir));
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.IDLE, null, null, 0);
		
		//Delete all the playpen directories that were created and not clean
		req_080_Util.deleteEnvDirs();
	}
	
	/**
	 *    1. Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *    5. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    6. Verify if the playpen directory exists and contains no files;
	 *    7. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *    8. Copy the file test_080_16.txt to the playpen directory;
	 *    9. Set the playpen root directory read-only
	 *   10. The master peer sends again a setPeer message to the Worker;
	 *       *  Verify if the following warn message was logged: The peer [peerID2] set itself as manager of this Worker. This message was ignored. Because the master peer did not notify fail.
	 *   11. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDir"
	 *   12. Set the playpen root directory read-write
	 *   13. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *      	 * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   14. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   15. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   16. Verify if the playpen directory exists and contains no files;
	 *   17. Copy the file test_080_16.txt to the playpen directory;
	 *   18. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirA"
	 *   19. Set the playpen root directory read-only
	 *   20. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirA].
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   21. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   22. Set the playpen root directory read-write
	 *   23. A client with the public key "mgPublicKey222", with a different ID, sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   24. Verify if the new playpen directory exists and contains no files;
	 *   25. Copy the file test_080_16.txt to the playpen directory;
	 *   26. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirB"
	 *   27. Set the playpen root directory read-only
	 *   28. A client with the public key "mgPublicKey222", with a different ID, sends a startWork message;
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirB].
	 *           * Verify if the following error message was logged: The client [clientID2] tried to start the work of this Worker, but the playpen directory [playpenDir] cannot be created.
	 *           * Expect the Worker to send the client an error ocurred message with the IO_ERROR type
	 *   29. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   30. A client with the public key "mgPublicKey222" sends a getFileInfo message, requesting info about the "$STORAGE" directory;
	 *           * Verify if the following debug message was logged: "The client requested info about the file [$STORAGE], but this Worker was not commanded to start the work yet. This message was ignored. Client public key: [mgPublicKey1]."
	 *   31. Set the playpen root directory read-write
	 *   32. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   33. Verify if the new playpen directory exists and contains no files;
	 *   34. Copy the file test_080_16.txt to the playpen directory;
	 *   35. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirD"
	 *   36. Set the playpen root directory read-only
	 *   37. Pause the Worker;
	 *           * Verify if the following info message was logged: "Worker has been PAUSED."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirD].
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to OWNER."
	 *           * Expect the Worker to send the peer a status changed message, with the OWNER status
	 *   38. Set the playpen root directory read-write
	 *   39. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   40. Resume the Worker;
	 *           * Verify if the following info message was logged: "Worker has been RESUMED."
	 *           * Verify if the following debug message was logged: "Status changed from OWNER to IDLE."
	 *           * Verify if the ControlClient received the operation succeed message
	 *   41. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   42. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   43. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey333";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey333]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   44. A client with the public key "mgPublicKey333" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   45. Verify if the playpen directory exists and contains no files;
	 *   46. Set the playpen root directory read-only
	 *   47. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirE"
	 *   48. The master peer commands the Worker to work for a peer with the publicKey peerPubKey222;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey222]."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirE].
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   49. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   50. Set the playpen root directory read-write
	 *   51. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey444";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey444]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   52. A client with the public key "mgPublicKey444" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID4].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   53. Verify if the playpen directory exists and contains no files;
	 *   54. Copy the file test_080_16.txt to the playpen directory;
	 *   55. Set the playpen root directory read-only
	 *   56. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirF"
	 *   57. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey555";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey555]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirF].
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   58. Set the playpen root directory read-write;
	 *   59. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   60. A client with the public key "mgPublicKey555" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID5].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   61. Verify if the new playpen directory exists and contains no files;
	 *   62. Copy the file test_080_16.txt to the playpen directory;
	 *   63. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirG"
	 *   64. Set the playpen root directory read-only;
	 *   65. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirG].
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   66. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   67. Set the playpen root directory read-write;
	 *   68. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   69. Verify if the new playpen directory exists and contains no files;
	 *   70. Copy the file test_080_16.txt to the playpen directory;
	 *   71. Set the playpen root directory read-only;
	 *   72. Get Worker complete status;
	 *           * Verify if the playpen directory is "playpenDirH"
	 *   73. The master peer sends a stopWorking message to the Worker;
	 *           * Verify if the following info message was logged: "This Worker was commanded to stop working for the current client."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDirH].
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to IDLE."
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *   74. Set the playpen root directory read-write;
	 *   75. Get Worker complete status;
	 *           * Verify if the playpen directory is null
	 *   76. Delete all the playpen directories that were created and not clean;
	 * 
	 */
	@ReqTest(test=" AT-080.13", reqs="REQ080")
	@Test public void test_at_080_13_CleaningWorkerWithError() throws Exception {
		//Start Worker with idleness detector DISABLED
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		WorkerComponent component = req_004_Util.startWorker();
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey222");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);

		//Verify if the playpen directory is null
		/*req_095_Util.getCompleteStatus(peerID, WorkerStatus.ALLOCATED_FOR_MYGRID, null, null, 0);*/
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		DeploymentID myGrid0ID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey222"), "myGrid");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the playpen directory exists and contains no files
		String playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		File pDir = new File(playpenPath);
		
		String storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		File sDir = new File(storagePath);
		
		Map<String, String> envVars = new HashMap<String, String>();
		String playpenDir = pDir.getAbsolutePath();
		String storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenRoot = (String) properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDir)); 
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDir));
		
		//Verify if the playpen directory is "playpenDir"
		String storageRoot = (String) properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		String hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey222");
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);

		//Copy the file test_080_16.txt to the playpen directory
		String filePath = playpenDir + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Set the playpen root directory read-only
		File playpenRootDir = new File(playpenRoot);
		playpenRootDir.setReadOnly();

		//The master peer sends again a setPeer message to the Worker
		req_090_Util.setPeerByMasterPeerFromSameLocation(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, wmc);
		
		//Verify if the playpen directory is "playpenDir"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey222");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirA = playpenRoot + File.separator + playpenDirAName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirA));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirA));
	
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirA + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Verify if the playpen directory is "playpenDirA"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-only
		boolean SOimplementsReadable = JavaFileUtil.setNonReadable(pDir);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222",
		// expect a error to be logged
		
		if (SOimplementsReadable) {
			req_092_Util.workForMyGridOnAllocatedForMyGridWorkerWithCleaningError(component, wmc, "mgPublicKey222", playpenDirA);
			worker = req_092_Util.beginAllocationCompleted(component, wmc);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		}	
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//A client with the public key "mgPublicKey222", with a different ID, sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mg1UserName", "mg1Server", "mg1Module", "mgPublicKey222"), "myGrid1");
		
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirB = playpenRoot + File.separator + playpenDirBName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirB));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirB));
		
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirB + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Verify if the playpen directory is "playpenDirB"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		//A client with the public key "mgPublicKey222", with a different ID, sends a startWork message,
		// expect a error to be logged
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mg2UserName", "mg2Server", "mg2Module", "mgPublicKey222"), "myGrid2");
		
		if (SOimplementsReadable) {
			req_079_Util.startWorkWithCleaningError(component, worker, myGrid2ID, playpenRoot, playpenDirB);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		}	
		
		//A client with the public key "mgPublicKey1" sends a getFileInfo message,
		// requesting info about the "$STORAGE" directory - expect a error to be logged
		req_082_Util.getFileInfoByUnknownClient(component, "$STORAGE", "mgPublicKey1");
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		req_079_Util.startWorkSuccessfullyCleaning(component, worker, myGrid1ID);
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirD = playpenRoot + File.separator + playpenDirDName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirD));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirD));
		
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirD + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);

		//Verify if the playpen directory is "playpenDirD"
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		if (SOimplementsReadable) {
			//Pause the Worker - expect a error to be logged
			req_087_Util.pauseAllocatedForMyGridWorkerWithCleaningError(component, wmc, playpenDirD);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.OWNER, null, null, 0);
		} else {
			req_087_Util.pauseAllocatedForMyGridWorker(component, wmc);
		}
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//Resume the Worker
		req_088_Util.resumeOwnerWorker(wmc, component);
		
		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_PEER, null, null, 0);
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work for 
		// the remote client with the public key "mgPublicKey333"
		req_092_Util.workForMyGridOnAllocatedForPeerWorker(component, wmc, "mgPublicKey333");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey333" sends a startWork message
		DeploymentID myGrid3ID = new DeploymentID(new ContainerID("mg3UserName", "mg3Server", "mg3Module", "mgPublicKey333"), "myGrid3");
		req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//Verify if the directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirE = playpenRoot + File.separator + playpenDirEName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirE));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirE));
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		//Verify if the playpen directory is "playpenDirE"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey333");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		if (SOimplementsReadable) {
			//The master peer commands the Worker to work for a peer with the publicKey peerPubKey222
			req_006_Util.workForPeerOnAllocatedForMyGridWorkerWithCleaningError(component, wmc, peerID.getPublicKey(), "peerPubKey222", playpenDirE);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_PEER, null, null, 0);
		} else {
			req_006_Util.workForPeerOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey(), "peerPubKey222");
		}
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//The remote peer with the public key "peerPubKey222" commands the Worker to work for
		// the remote client with the public key "mgPublicKey444"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey222", "mgPublicKey444");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey444" sends a startWork message
		DeploymentID myGrid4ID = new DeploymentID(new ContainerID("mg4UserName", "mg4Server", "mg4Module", "mgPublicKey444"), "myGrid4");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid4ID);
		
		//Verify if the directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirF = playpenRoot + File.separator + playpenDirFName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirF));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirF));
		
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirF + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		//Verify if the playpen directory is "playpenDirF"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey444");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		if (SOimplementsReadable) {
			//The remote peer with the public key "peerPubKey222" commands the Worker to work 
			// for the remote client with the public key "mgPublicKey555" - expect a error to be logged
			rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorkerWithCleaningError(component, "peerPubKey222",
					"mgPublicKey555", playpenDirF);
			worker = req_121_Util.beginAllocationCompleted(component, rwmc);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		} else {
			rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorker(component, "peerPubKey222", "mgPublicKey555");
			worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		}
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//A client with the public key "mgPublicKey555" sends a startWork message
		DeploymentID myGrid5ID = new DeploymentID(new ContainerID("mg5UserName", "mg5Server", "mg5Module", "mgPublicKey555"), "myGrid5");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid5ID);
		
		//Verify if the playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirG = playpenRoot + File.separator + playpenDirGName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirG));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirG));
		
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirG + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Verify if the playpen directory is "playpenDirG"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey555");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		if (SOimplementsReadable) {
			//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
			req_092_Util.workForMyGridOnAllocatedForMyGridWorkerWithCleaningError(component, wmc,
					"mgPublicKey222", playpenDirG);
			worker = req_092_Util.beginAllocationCompleted(component, wmc);
			
			//Verify if the playpen directory is null
			req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, null, null, 0);
		} else {
			req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey222");
			worker = req_092_Util.beginAllocationCompleted(component, wmc);
		}
		
		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Verify if the new playpen directory exists and contains no files
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirH = playpenRoot + File.separator + playpenDirHName;
		assertTrue(WorkerAcceptanceUtil.directoryExists(playpenDirH));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(playpenDirH));
		
		//Copy the file test_080_16.txt to the playpen directory
		filePath = playpenDirH + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		//Verify if the playpen directory is "playpenDirH"
		hashedMGPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString("mgPublicKey222");
		storageDir = storageRoot + File.separator + hashedMGPubKey;
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		if (SOimplementsReadable) {
			//The master peer sends a stopWorking message to the Worker
			req_091_Util.stopWorkingOnAllocatedForMyGridWorkerWithCleaningError(component, wmc, peerID.getPublicKey(), playpenDirH);
		} else {
			req_091_Util.stopWorkingOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey());
		}

		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey222");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfully(component, worker, myGrid0ID);
		
		//Copy the file test_080_16.txt to the playpen directory
		playpenPath = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		pDir = new File(playpenPath);
		
		storagePath = component.getDAO(EnvironmentDAO.class).getStorageDir();
		sDir = new File(storagePath);
		
		envVars = new HashMap<String, String>();
		playpenDir = pDir.getAbsolutePath();
		storageDir = sDir.getAbsolutePath();
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		
		String playpenDirI = playpenRoot + File.separator + playpenDirIName;
		filePath = playpenDirI + File.separator + "test_080_16.txt";
		WorkerAcceptanceUtil.createFile(filePath);
		
		//Verify if the playpen directory is null
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenPath, storagePath, 0);
		
		//Set the playpen root directory read-only
		playpenRootDir.setReadOnly();
		
		if (SOimplementsReadable) {
			//Stop Worker - expect a error to be logged
			req_120_Util.stopWorkerWithCleaningError(component, playpenDirI);
		} else {
			req_120_Util.stopWorker(component);
		}

		//Set the playpen root directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);

		//Delete all the playpen directories that were created and not clean
		req_080_Util.deleteEnvDirs();
	}

	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. A client with the public key "mgPublicKey222" requests to transfer the file "file222", with size 512 bytes and the handle "222";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey222] File destination: [playpenDir/file222]. File size: 512 bytes. Handle: 222.
	 *           * Expect the Worker to accept the file transfer;
	 *    6. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "222";
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    7. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    8. A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2", with size 512 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file2]. File size: 512 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *    9. A client with the public key "mgPublicKey1" requests to transfer the file "etc/file3", with size 512 bytes and the handle "3";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file3]. File size: 512 bytes. Handle: 3.
	 *           * Expect the Worker to accept the file transfer;
	 *   10. A client with the public key "mgPublicKey1", with a different ID, sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID2].
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "2";
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "3";
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   11. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 2.
	 *   12. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 3 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 3.
	 *   13. A client with the public key "mgPublicKey1" requests to transfer the file "file2", with size 512 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file2]. File size: 512 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   14. Pause the Worker;
	 *           * Verify if the following info message was logged: "Worker has been PAUSED."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "2";
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to OWNER."
	 *           * Expect the Worker to send the peer a status changed message, with the OWNER status
	 *   15. Resume the Worker;
	 *           * Verify if the following info message was logged: "Worker has been RESUMED."
	 *           * Verify if the following debug message was logged: "Status changed from OWNER to IDLE."
	 *           * Verify if the ControlClient received the operation succeed message
	 *   16. The master peer sends a workForPeer message to the Worker;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   17. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey333";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey333]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   18. A client with the public key "mgPublicKey333" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   19. A client with the public key "mgPublicKey333" requests to transfer the file "usr/local/file333", with size 512 bytes and the handle "333";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey333] File destination: [playpenDir/usr/local/file333]. File size: 512 bytes. Handle: 333.
	 *           * Expect the Worker to accept the file transfer;
	 *   20. Set the playpen directory read-only
	 *   21. The master peer commands the Worker to work for a peer with the publicKey peerPubKey222;
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey222]."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDir].
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "333";
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to ALLOCATED_FOR_PEER."
	 *           * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
	 *   22. Set the playpen directory read-write;
	 *   23. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey444";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey444]."
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   24. A client with the public key "mgPublicKey444" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID4].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   25. A client with the public key "mgPublicKey444" requests to transfer the file "hosts", with size 512 bytes and the handle "8";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey444] File destination: [playpenDir/hosts]. File size: 512 bytes. Handle: 8.
	 *           * Expect the Worker to accept the file transfer;
	 *   26. A client with the public key "mgPublicKey444" requests to transfer the file "file5", with size 512 bytes and the handle "5";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey444] File destination: [playpenDir/file5]. File size: 512 bytes. Handle: 5.
	 *           * Expect the Worker to accept the file transfer;
	 *   27. The remote peer with the public key "peerPubKey222" commands the Worker to work for the remote client with the public key "mgPublicKey555";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey555]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "5";
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "8";
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   28. A client with the public key "mgPublicKey555" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID5].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   29. A client with the public key "mgPublicKey555" requests to transfer the file "file555", with size 512 bytes and the handle "2";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey555] File destination: [playpenDir/file555]. File size: 512 bytes. Handle: 2.
	 *           * Expect the Worker to accept the file transfer;
	 *   30. A client with the public key "mgPublicKey555" requests to transfer the file "file123", with size 512 bytes and the handle "3";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey555] File destination: [playpenDir/file123]. File size: 512 bytes. Handle: 3.
	 *           * Expect the Worker to accept the file transfer;
	 *   31. Set the playpen directory read-only;
	 *   32. The master peer commands the Worker to work for the client with the public key "mgPublicKey222";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey222]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Verify if the following error message was logged: Error while trying to clean the playpen directory [playpenDir].
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "3";
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "2";
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   33. Set the playpen directory read-write;
	 *   34. A client with the public key "mgPublicKey222" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   35. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *           * Expect the Worker to accept the file transfer;
	 *   36. The master peer sends a stopWorking message to the Worker;
	 *           * Verify if the following info message was logged: "This Worker was commanded to stop working for the current client."
	 *           * Verify if the following debug message was logged: "Cleaning Worker."
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "1";
	 *           * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_MYGRID to IDLE."
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *   37. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   38. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 1.
	 *   39. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 2 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 2.
	 *   40. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 3 and 2 bytes of written data;
	 *           * Verify if the following warn message was logged: The Worker received an incoming transfer completed message with unknown handle. Client public key: [mgPublicKey1].Handle: 3.
	 *   41. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   42. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *   43.  The master peer sends again a setPeer message to the Worker;
     *			 * Verify if the following warn message was logged: The peer [peerID2] set itself as manager of this Worker. This message was ignored. Because the master peer did not notify fail.
	 *   44. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "1";
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   45. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID0].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   46. A client with the public key "mgPublicKey1" requests to transfer the file "file1", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *   47. Stop the Worker with the correct public key;
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to cancel the incoming file transfer with the handle "1";
	 *           * Verify if the following info message was logged: "Worker has been successfully shutdown."
	 *   48. Delete all the playpen directories that were created and not clean;
	 * 
	 */
	@ReqTest(test=" AT-080.14", reqs="REQ080")
	@Test public void test_at_080_14_WorkerPreemptionOnTransferFile() throws Exception {
		//Start a Worker with the idleness detector DISABLED
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);
		WorkerComponent component = req_004_Util.startWorker();

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);

		//Master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey222");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);

		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		DeploymentID myGridID = new DeploymentID(new ContainerID("mgUserName", "mgServer", "mgModule", "mgPublicKey222"), "myGrid");

		DeploymentID workerID = workerAcceptanceUtil.getWorkerDeployment().getDeploymentID();
		
		req_079_Util.startWorkSuccessfully(component, worker, myGridID);
		
		ContainerID senderID = new ContainerID("client", "clientServer", "broker", "mgPublicKey1");
		ContainerID senderID2 = new ContainerID("client2", "clientServer", "broker", "mgPublicKey222");
		ContainerID senderID3 = new ContainerID("client3", "clientServer", "broker", "mgPublicKey333");
		ContainerID senderID4 = new ContainerID("client4", "clientServer", "broker", "mgPublicKey444");
		ContainerID senderID5 = new ContainerID("client5", "clientServer", "broker", "mgPublicKey555");
		
		//A client with the public key "mgPublicKey222" requests to transfer the file "file222",
		// with size 512 bytes and the handle "222"
		IncomingTransferHandle handle = new IncomingTransferHandle(222, "file222", 1L, "file222", "PUT", myGridID.getContainerID());
		req_080_Util.requestToTransferFile(component, 1, senderID2, "file222",
				handle, 512);
		
		List<TransferHandle> handles = new ArrayList<TransferHandle>();
		handles.add(handle);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorkerWithFileOnTransfer(component, wmc,
				"mgPublicKey1", true, handles);
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(senderID, "myGrid1");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$PLAYPEN/file2",
		// with size 512 bytes and the handle "2"
		IncomingTransferHandle handle1 = new IncomingTransferHandle(2, "$PLAYPEN/file2", 1L, "$PLAYPEN/file2", "PUT", senderID);
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/file2", 
				handle1, 512);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "etc/file3",
		// with size 512 bytes and the handle "3"
		IncomingTransferHandle handle2 = new IncomingTransferHandle(3, "etc/file3", 1L, "etc/file3", "PUT", senderID);
		req_080_Util.requestToTransferFile(component, 1, senderID, "etc/file3", 
				handle2, 512);
		
		//A client with the public key "mgPublicKey1", with a different ID, sends a startWork message
		DeploymentID myGrid2ID = new DeploymentID(senderID, "myGrid2");
		
		handles = new ArrayList<TransferHandle>();
		handles.add(handle1);
		handles.add(handle2);
		
		//A client with the public key "mgPublicKey1", with a different ID, sends a startWork message
		req_079_Util.startWorkSuccessfullyWithFileOnTransfer(component, worker, myGrid2ID, true, handles);
		
		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 2 and 2 bytes of written data - expect a warn to be logged
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker, 
				handle1, 2, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1",
		// for the file transfer with handle 3 and 2 bytes of written data
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker, 
				handle2, 2, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file2",
		// with size 512 bytes and the handle "2"
		req_080_Util.requestToTransferFile(component, 1, senderID, "$PLAYPEN/file2", 
				handle1, 512);
		
		//Pause the Worker
		handles = new ArrayList<TransferHandle>();
		handles.add(handle1);
		
		req_087_Util.pauseAllocatedForMyGridWorkerWithFileOnTransfer(component, wmc, true, handles);
		
		//Resume the Worker
		req_088_Util.resumeOwnerWorker(wmc, component);
		
		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work for
		// the remote client with the public key "mgPublicKey333"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey333");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey333" sends a startWork message
		DeploymentID myGrid3ID = new DeploymentID(senderID3, "myGrid3");
		
		RandomNumberUtil.setSeed(0);
		req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//A client with the public key "mgPublicKey333" requests to transfer the file "usr/local/file333"",
		// with size 512 bytes and the handle "333"
		IncomingTransferHandle handle3 = new IncomingTransferHandle(333, "usr/local/file333", 1L, "usr/local/file333",
				"PUT", senderID3);
		req_080_Util.requestToTransferFile(component, 1, senderID3, "usr/local/file333", 
				handle3, 512);
		
		//Set the playpen directory read-only
		String playpenRoot = (String) properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		File playpenRootDir = new File(playpenRoot);
		
		playpenRootDir.setReadOnly();

		//The master peer commands the Worker to work for a peer with the public key "peerPubKey222"
		// expect a error to be logged
		handles = new ArrayList<TransferHandle>();
		handles.add(handle3);

		String playpenDir = playpenRoot + File.separator + playpenDirName;
		
		boolean SOimplementsReadable = JavaFileUtil.setNonReadable(playpenRootDir);
		
		if (SOimplementsReadable) {
			req_006_Util.workForPeerOnAllocatedForMyGridWorkerWithCleaningErrorAndFileOnTransfer(component, wmc, peerID.getPublicKey(), 
					"peerPubKey222", playpenDir, handles);
		} else {
			req_006_Util.workForPeerOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey(), "peerPubKey222");
		}
		
		//Set the playpen directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		JavaFileUtil.setReadable(playpenRootDir);
		
		//The remote peer with the public key "peerPubKey222" commands the Worker to work
		// for the remote client with the public key "mgPublicKey444"
		rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey222", "mgPublicKey444");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey444" sends a startWork message
		DeploymentID myGrid4ID = new DeploymentID(senderID4, "myGrid4");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid4ID);
		
		//A client with the public key "mgPublicKey444" requests to transfer the file "hosts",
		// with size 512 bytes and the handle "8"
		IncomingTransferHandle handle4 = new IncomingTransferHandle(8, "hosts", 1L, "hosts", "PUT", senderID4);
		req_080_Util.requestToTransferFile(component, 1, senderID4, "hosts", 
				handle4, 512);
		
		//A client with the public key "mgPublicKey444" requests to transfer the file "file5"",
		// with size 512 bytes and the handle "5"
		IncomingTransferHandle handle5 = new IncomingTransferHandle(5, "file5", 1L, "file5", "PUT", senderID4);
		req_080_Util.requestToTransferFile(component, 1, senderID4, "file5", 
				handle5, 512);
		
		//The remote peer with the public key "peerPubKey222" commands the Worker to work for
		// the remote client with the public key "mgPublicKey555"
		handles = new ArrayList<TransferHandle>();
		handles.add(handle4);
		handles.add(handle5);

		rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorkerWithFileOnTransfer(component, "peerPubKey222", "mgPublicKey555",
				true, handles);
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);

		//A client with the public key "mgPublicKey555" sends a startWork message
		DeploymentID myGrid5ID = new DeploymentID(senderID5, "myGrid5");
		
		req_079_Util.startWorkSuccessfully(component, worker, myGrid5ID);
		
		//A client with the public key "mgPublicKey555" requests to transfer the file "file555",
		// with size 512 bytes and the handle "2"
		handle2 = new IncomingTransferHandle(2, "file555", 1L, "file555", "PUT", senderID5);
		req_080_Util.requestToTransferFile(component, 1, senderID5, "file555", 
				handle2, 512);
		
		//A client with the public key "mgPublicKey555" requests to transfer the file "file123",
		// with size 512 bytes and the handle "3"
		handle3 = new IncomingTransferHandle(3, "file123", 1L, "file123", "PUT", senderID5);
		req_080_Util.requestToTransferFile(component, 1, senderID5, "file123", 
				handle3, 512);

		//Set the playpen directory read-only
		playpenRootDir.setReadOnly();
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey222"
		String playpenDirB = playpenRoot + File.separator + playpenDirBName;
		handles = new ArrayList<TransferHandle>();
		handles.add(handle2);
		handles.add(handle3);
		
		SOimplementsReadable = JavaFileUtil.setNonReadable(playpenRootDir);
		if (SOimplementsReadable) {
			req_092_Util.workForMyGridOnAllocatedForMyGridWorkerWithCleaningErrorAndFileOnTransfer(component,
					wmc, "mgPublicKey222", playpenDirB, handles);
			worker = req_092_Util.beginAllocationCompleted(component, wmc);
		} else {
			req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey222");
			worker = req_092_Util.beginAllocationCompleted(component, wmc);
		}
		
		//Set the playpen directory read-write
		JavaFileUtil.setReadAndWrite(playpenRootDir);
		
		//A client with the public key "mgPublicKey222" sends a startWork message
		myGrid2ID = new DeploymentID(senderID2, "myGrid222");
		req_079_Util.startWorkSuccessfully(component, worker, myGrid2ID);

		//A client with the public key "mgPublicKey222" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		handle1 = new IncomingTransferHandle(1, "file1", 1L, "file1", "PUT", senderID2);
		req_080_Util.requestToTransferFile(component, 1, senderID2, "file1", 
				handle1, 512);
		
		//The master peer sends a stopWorking message to the Worker
		handles = new ArrayList<TransferHandle>();
		handles.add(handle1);
		
		req_091_Util.stopWorkingOnAllocatedForMyGridWorkerWithFileOnTranfer(
				component, wmc, peerID.getPublicKey(), true, handles);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
	
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 2 bytes of written data - expect a warn to be logged
		handle1 = new IncomingTransferHandle(1, "file1", 1L, "file1", "PUT", senderID);
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker, handle1, 2, "mgPublicKey1");
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 2 and 2 bytes of written data - expect a warn to be logged
		handle2 = new IncomingTransferHandle(2, "file555", 1L, "file555", "PUT", senderID);
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker, 
				handle2, 2, "mgPublicKey1");		

		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 3 and 2 bytes of written data - expect a warn to be logged
		handle3 = new IncomingTransferHandle(3, "file123", 1L, "file123", "PUT", senderID);
		req_080_Util.receiveIncomingTransferCompletedWithUnknownHandle(component, worker, 
				handle3, 2, "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		myGridID = new DeploymentID(senderID, "myGrid1");
		req_079_Util.startWorkSuccessfully(component, worker, myGridID);

		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				handle1, 512);

		//The master peer sends again a setPeer message to the Worker
		req_090_Util.setPeerByMasterPeerFromSameLocation(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, wmc);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, "mgPublicKey1");
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		req_079_Util.startWorkSuccessfully(component, worker, myGridID);
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "file1",
		// with size 512 bytes and the handle "1"
		req_080_Util.requestToTransferFile(component, 1, senderID, "file1", 
				handle1, 512);
		
		//Stop the Worker
		handles = new ArrayList<TransferHandle>();
		handles.add(handle1);
		
		req_120_Util.stopWorkerWithFileOnTransfer(component, true, handles);
		
		//Delete all the playpen directories that were created and not clean
		workerAcceptanceUtil.deleteEnvDirs();
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
	 *    2. The master peer sends a setPeer message to the Worker;
	 *           * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
	 *           * Expect the Worker to send a status changed message to the peer, with the IDLE status
	 *    3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    4. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *    5. Get Worker complete status;
	 *           * Verify if the storage directory is "storageRoot/mgPublicKey1Hash"
	 *    6. Verify if the storage directory exists and contains no files;
	 *    7. A client with the public key "mgPublicKey1" requests to transfer the file "test_080_14_1.txt", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1]. File destination: [playpenDir/test_080_14_1.txt]. File size: 512 bytes. Handle: 1.
	 *    8. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 512 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 512 bytes.
	 *    9. Copy the file test_080_14_1.txt to the storage directory;
	 *   10. A client with the public key "mgPublicKey1" sends a getFileInfo message, requesting info about the "test_080_14_1.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/mgPublicKey1Hash/test_080_14_1.txt]. Client public key: [mgPublicKey1]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/mgPublicKey1Hash/test_080_14_1.txt" and md5sum "X"
	 *   11. The master peer commands the Worker to work for the client with the public key "mgPublicKey2";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey2]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   12. A client with the public key "mgPublicKey2" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID2].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   13. A client with the public key "mgPublicKey2" sends a getFileInfo message, requesting info about the "test_080_14_1.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/mgPublicKey2Hash/test_080_14_1.txt]. Client public key: [mgPublicKey2]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/mgPublicKey2Hash/test_080_14_1.txt" and md5sum "0"
	 *   14. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   15. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   16. A client with the public key "mgPublicKey1" sends a getFileInfo message, requesting info about the "test_080_14_1.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/mgPublicKey1Hash/test_080_14_1.txt]. Client public key: [mgPublicKey1]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/mgPublicKey1Hash/test_080_14_1.txt" and md5sum "X"
	 *   17. A client with the public key "rMgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   18. Get Worker complete status;
	 *           * Verify if the storage directory is "storageRoot/rMgPublicKey1Hash"
	 *   19. Verify if the storage directory exists and contains no files;
	 *   20. A client with the public key "rMgPublicKey1" requests to transfer the file "test_080_14_2.txt", with size 512 bytes and the handle "1";
	 *           * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [rMgPublicKey1]. File destination: [playpenDir/test_080_14_2.txt]. File size: 512 bytes. Handle: 1.
	 *   21. The Worker receives an incoming transfer completed message from the client with the public key "mgPublicKey1", for the file transfer with handle 1 and 512 bytes of written data;
	 *           * Verify if the following debug message was logged: File successfully received from client. Client public key: [rMgPublicKey1]. Handle: 1. Amount of data received: 512 bytes.
	 *   22. Copy the file test_080_14_2.txt to the storage directory;
	 *   23. A client with the public key "rMgPublicKey1" sends a getFileInfo message, requesting info about the "test_080_14_2.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/rMgPublicKey1Hash/test_080_14_2.txt]. Client public key: [rMgPublicKey1]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/rMgPublicKey1Hash/test_080_14_2.txt" and md5sum "X"
	 *   24. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "rMgPublicKey2";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [rMgPublicKey2]."
	 *           * Verify if the following info message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   25. A client with the public key "rMgPublicKey2" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID4].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   26. A client with the public key "rMgPublicKey2" sends a getFileInfo message, requesting info about the "test_080_14_1.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/rMgPublicKey2Hash/test_080_14_2.txt]. Client public key: [rMgPublicKey2]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/rMgPublicKey2Hash/test_080_14_1.txt" and md5sum "0"
	 *   27. A client with the public key "rMgPublicKey2" sends a getFileInfo message, requesting info about the "test_080_14_2.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/rMgPublicKey2Hash/test_080_14_2.txt]. Client public key: [rMgPublicKey2]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/rMgPublicKey2Hash/test_080_14_2.txt" and md5sum "0"
	 *   28. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "rMgPublicKey1";
	 *           * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [rMgPublicKey1]."
	 *           * Verify if the following info message was logged: "Cleaning Worker."
	 *           * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   29. A client with the public key "rMgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID3].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   30. Verify if the storage directory exists and contains files;
	 *   31. A client with the public key "rMgPublicKey1" sends a getFileInfo message, requesting info about the "test_080_14_2.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/rMgPublicKey1Hash/test_080_14_2.txt]. Client public key: [rMgPublicKey1]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/rMgPublicKey1Hash/test_080_14_2.txt" and md5sum "X"
	 *   32. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
	 *           * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
	 *           * Verify if the following debug message was logged: Cleaning Worker.
	 *           * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *   33. A client with the public key "mgPublicKey1" sends a startWork message;
	 *           * Verify if the following info message was logged: Worker is ready to start working for client [ClientID1].
	 *           * Expect the Worker to send the client a Worker is Ready message
	 *   34. Verify if the storage directory exists and contains files;
	 *   35. A client with the public key "mgPublicKey1" sends a getFileInfo message, requesting info about the "test_080_14_1.txt" file;
	 *           * Verify if the following debug message was logged: "Client successfully got file info. File: [storageRoot/mgPublicKey1Hash/test_080_14_1.txt]. Client public key: [mgPublicKey1]"
	 *           * Expect the Worker to return to the client information about the file, with file path "storageRoot/mgPublicKey1Hash/test_080_14_1.txt" and md5sum "X"
	 *   36. Stop the Worker with the correct public key;
	 *           * Verify if the following info message was logged: "Cleaning Worker."
	 *           * Verify if the following info message was logged: "Worker has been successfully shutdown."
	 *   37. Verify if the storage directory exists and contains files;
	 *   38. Delete all the playpen directories that were created and not clean;
	 *   
	 */
	@ReqTest(test=" AT-080.15", reqs="REQ080")
	@Test public void test_at_080_15_StoragePersistence() throws Exception {
		//Start a Worker with the idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		long initialTick = System.currentTimeMillis();
		
		Map<String, Object> properties = workerAcceptanceUtil.createWorkerProperties(false);

		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(component, peerID, WorkerStatus.IDLE);

		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		String mgPublicKey1 = "mgPublicKey1";
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, mgPublicKey1);
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);

		//A client with the public key "mgPublicKey1" sends a startWork message
		DeploymentID myGrid1ID = new DeploymentID(new ContainerID("mg1UserName", "mg1Server", "mg1Module", mgPublicKey1), "myGrid1");
		
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);

		//Verify if the storage directory is "storageRoot/mgPublicKey1Hash"
		String playpenRoot = (String) properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String storageRoot = (String) properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		String playpenDir = component.getDAO(EnvironmentDAO.class).getPlaypenDir();
		String hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(mgPublicKey1);
		String storageDir = component.getDAO(EnvironmentDAO.class).getStorageDir();
		
		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER,
				playpenDir, storageDir, initialTick);
		
		//Verify if the storage directory exists and contains no files
		assertTrue(WorkerAcceptanceUtil.directoryExists(storageDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(storageDir));
		
		DeploymentID workerID = workerAcceptanceUtil.getWorkerDeployment().getDeploymentID();
		
		ContainerID senderID = myGrid1ID.getContainerID();//new ContainerID("client", "clientServer", "broker", "mgPublicKey1");
		
		//A client with the public key "mgPublicKey1" requests to transfer the file "$STORAGE/test_080_14_1.txt",
		// with size 512 bytes and the handle "1"
		String file1Name ="test_080_14_1.txt";
		req_080_Util.requestToTransferFile(component, 1L, senderID, file1Name,
				new IncomingTransferHandle(1, file1Name, 1L, file1Name, "STORE", senderID), 512);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 512 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker, new IncomingTransferHandle(1L, file1Name, 512,
				file1Name, "PUT", senderID), 512, "mgPublicKey1");

		//Copy the file test_080_14_1.txt to the storage directory
		String file1Path = storageDir + File.separator + file1Name;
		WorkerAcceptanceUtil.createFile(file1Path);

		//Client "mgPublicKey1" sends a getFileInfo "$STORAGE/test_080_14_1.txt" message
		String fileDigest = Req_082_Util.getFileDigest(file1Path);
		req_082_Util.getFileInfoSuccessfully(component, workerClient, mgPublicKey1, "$STORAGE" +File.separator+ file1Name,
				file1Path, fileDigest);
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey2"
		String myGridPubKey2 = "mgPublicKey2";
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, myGridPubKey2);
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
	
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey2"
		DeploymentID myGrid2ID = new DeploymentID(new ContainerID("mg2UserName", "mg2Server", "mg2Module", myGridPubKey2), "myGrid2");
		
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid2ID);
		
        //Client "mgPublicKey2" sends a getFileInfo "$STORAGE/test_080_14_1.txt" message
		hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(myGridPubKey2);
		storageDir = storageRoot + File.separator + hashedMyGridPubKey;
		
		req_082_Util.getFileInfoSuccessfully(component, workerClient, myGridPubKey2, "$STORAGE" + File.separator + file1Name,
				storageDir + File.separator + file1Name, "0");
		
		//The master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, mgPublicKey1);
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
	
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//Client "mgPublicKey1" sends a getFileInfo "$STORAGE/test_080_14_1.txt" message
		req_082_Util.getFileInfoSuccessfully(component, workerClient, mgPublicKey1, file1Name, file1Path, fileDigest);

		//The master peer sends a workForPeer message to the Worker
		req_006_Util.workForPeerOnAllocatedForMyGridWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");

		//The remote peer with the public key "peerPubKey" commands the Worker to work
		// for the remote client with the public key "rMgPublicKey1"
		String rMgPubKey1 = "rMgPublicKey1";
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "rMgPublicKey1");
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "rMgPublicKey1" sends a startWork message
		DeploymentID myGrid3ID = new DeploymentID(
				new ContainerID("rMg1UserName", "rMg1Server", "rMg1Module", rMgPubKey1), "rMyGrid1");
		
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//Verify if the storage directory is "storageRoot/rMgPublicKey1Hash"
		playpenDir = playpenRoot;
		hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(rMgPubKey1);
		storageDir = storageRoot + File.separator + hashedMyGridPubKey;

		req_095_Util.getCompleteStatus(component, peerID, WorkerStatus.ALLOCATED_FOR_BROKER, playpenDir
				, storageDir, initialTick);

		//Verify if the storage directory exists and contains no files
		assertTrue(WorkerAcceptanceUtil.directoryExists(storageDir));
		assertFalse(WorkerAcceptanceUtil.directoryContainsFiles(storageDir));
		
		//new ContainerID("clientR", "clientServer", "broker", "rMgPublicKey1");
		ContainerID senderIDR = myGrid3ID.getContainerID();
		
		//A client with the public key "rMgPublicKey1" requests to transfer the file "$STORAGE/test_080_14_2.txt",
		// with size 512 bytes and the handle "1"
		String file2Name = "test_080_14_2.txt";
		req_080_Util.requestToTransferFile(component, 1, senderIDR, "$STORAGE" + File.separator + file2Name,
				new IncomingTransferHandle(1, "$STORAGE" + File.separator + file2Name, 1L,
						"$STORAGE" + File.separator + file2Name, "STORE", senderIDR), 512);
		
		//The Worker receives an incoming transfer completed message, for the file transfer 
		// with handle 1 and 512 bytes of written data
		req_080_Util.receiveIncomingTransferCompleted(component, worker,
				new IncomingTransferHandle(1L,file2Name, 512,
						file2Name, "STORE", senderIDR), 512, "rMgPublicKey1");

		//Copy the file test_080_14_2.txt to the storage directory
		String file2Path = storageDir + File.separator + "test_080_14_2.txt";
		WorkerAcceptanceUtil.createFile(file2Path);

		//Client "rMgPublicKey1" sends a getFileInfo "$STORAGE/test_080_14_2.txt" message
		fileDigest = Req_082_Util.getFileDigest(file2Path);
		req_082_Util.getFileInfoSuccessfully(component, workerClient, "rMgPublicKey1", "$STORAGE" + File.separator + file2Name,
				file2Path, fileDigest);

		//The remote peer with the public key "peerPubKey" commands the Worker to work
		// for the remote client with the public key "rMgPublicKey2"
		String rMgPubKey2 = "rMgPublicKey2";
		rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorker(component, "peerPubKey", rMgPubKey2);
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//The master peer commands the Worker to work for the client with the public key "rMgPublicKey2"
		DeploymentID myGrid4ID = new DeploymentID(
				new ContainerID("rMg2UserName", "rMg2Server", "rMg2Module", rMgPubKey2), "rMyGrid2");
		
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid4ID);
		
	    //Client "rMgPublicKey2" sends a getFileInfo "$STORAGE/test_080_14_1.txt" message
		hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(rMgPubKey2);
		storageDir = storageRoot + File.separator + hashedMyGridPubKey;
		req_082_Util.getFileInfoSuccessfully(component, workerClient, rMgPubKey2, "$STORAGE" + file1Name,
				storageDir + file1Name, "0");
		
	    //Client "rMgPublicKey2" sends a getFileInfo "$STORAGE/test_080_14_2.txt" message
		req_082_Util.getFileInfoSuccessfully(component, workerClient, rMgPubKey2, "$STORAGE" + file2Name,
				storageDir + file2Name, "0");
		
		//The remote peer with the public key "peerPubKey" commands the Worker to work
		// for the remote client with the public key "rMgPublicKey1"
		rwmc = req_121_Util.workForMyGridOnAllocatedForMyGridWorker(component, "peerPubKey", rMgPubKey1);
		worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "rMgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid3ID);
		
		//Verify if the storage directory exists and contains files
		hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(rMgPubKey1);
		storageDir = storageRoot + File.separator + hashedMyGridPubKey;

		assertTrue(WorkerAcceptanceUtil.directoryExists(storageDir));
		assertTrue(WorkerAcceptanceUtil.directoryContainsFiles(storageDir));
		
		//Client "rMgPublicKey1" sends a getFileInfo "$STORAGE/test_080_14_2.txt" message
		req_082_Util.getFileInfoSuccessfully(component, workerClient, "rMgPublicKey1",
				file2Name, file2Path, fileDigest);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnAllocatedForMyGridWorker(component, wmc, mgPublicKey1);
		worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" sends a startWork message
		workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGrid1ID);
		
		//Verify if the storage directory exists and contains files
		hashedMyGridPubKey = WorkerAcceptanceUtil.generateHexadecimalCodedString(rMgPubKey1);
		storageDir = storageRoot + File.separator + hashedMyGridPubKey;

		assertTrue(WorkerAcceptanceUtil.directoryExists(storageDir));
		assertTrue(WorkerAcceptanceUtil.directoryContainsFiles(storageDir));
		
		//Client "mgPublicKey1" sends a getFileInfo "$STORAGE/test_080_14_1.txt" message
		fileDigest = Req_082_Util.getFileDigest(file1Path);
		req_082_Util.getFileInfoSuccessfully(component, workerClient, mgPublicKey1,
				file1Name, file1Path, fileDigest);
		
		//Stop Worker
		req_120_Util.stopWorker(component);
		
		//Verify if the storage directory exists and contains files
		assertTrue(WorkerAcceptanceUtil.directoryExists(storageDir));
		assertTrue(WorkerAcceptanceUtil.directoryContainsFiles(storageDir));
		
		//Delete all playpen and storage directories that were created and not clean
		workerAcceptanceUtil.deleteEnvDirs();
	}
}